package com.atguigu.test2;

import java.util.HashMap;

public class lcTest1 {
    public static void main(String[] args) {
        int[] arrays = {1,11,22,33,77,99,103};
        int target = 55;
        for (int i = 0; i < arrays.length-1; i++) {
            for (int j = i+1; j < arrays.length; j++) {
                if (arrays[i]+arrays[j]==target){
                    System.out.println(i+","+j);
                }
            }
        }
    }
    public int[] twoSum2(int[] nums,int target){
        HashMap<Integer,Integer> map = new HashMap<>(nums.length);
        for (int i = 0; i < nums.length; i++) {
            int partnerNumber = target - nums[i];
            if (map.containsKey(partnerNumber)){
                return new int[]{map.get(partnerNumber),i};
            }
            map.put(nums[i],i);

        }
        return null;
    }

}
